package com.zb.zeus.system.api.domain.dto;

import com.zb.zeus.common.core.utils.StringUtils;

import org.springframework.util.CollectionUtils;

import java.util.List;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 发企业微信应用消息数据基类
 * @author liangfan
 * @date 2021/07/08 18:50
 **/

@Data
public abstract class BaseWxAppMsgDTO extends BaseWxMsgDTO implements IWxMsgDTO{

    @ApiModelProperty(value = "推送到企业微信uid. isAll=1时可以不传")
    private List<String> toWxUids;

    @ApiModelProperty(value = "消息类型. 1:all 其它 ", required = true, example = "0")
    private Integer isAll;

    @Override
    public String checkData(){
        String superCheck = super.checkData();
        if(!StringUtils.isBlank(superCheck)){
            return superCheck;
        }

        boolean hasWxUids = !CollectionUtils.isEmpty(toWxUids);

        if(isAll == 1 && hasWxUids){
            return "全推时，不能指定发送员工";
        }

        if(!hasWxUids){
            return "未指定推送用户";
        }
        return null;
    }
}
